using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_TravelTool {
		#region Fields
		private int iD;
		private int tTID;
		private string tTName;
		private string description;
		private string detail;
		private string imageURL;
		private int cityID;
		private int languageID;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_TravelTool class.
		/// </summary>
		public TF_TravelTool() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_TravelTool class.
		/// </summary>
		public TF_TravelTool(int tTID, string tTName, string description, string detail, string imageURL, int cityID, int languageID) {
			this.tTID = tTID;
			this.tTName = tTName;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.languageID = languageID;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_TravelTool class.
		/// </summary>
		public TF_TravelTool(int iD, int tTID, string tTName, string description, string detail, string imageURL, int cityID, int languageID) {
			this.iD = iD;
			this.tTID = tTID;
			this.tTName = tTName;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.languageID = languageID;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the TTID value.
		/// </summary>
		public int TTID {
			get { return tTID; }
			set { tTID = value; }
		}
		
		/// <summary>
		/// Gets or sets the TTName value.
		/// </summary>
		public string TTName {
			get { return tTName; }
			set { tTName = value; }
		}
		
		/// <summary>
		/// Gets or sets the Description value.
		/// </summary>
		public string Description {
			get { return description; }
			set { description = value; }
		}
		
		/// <summary>
		/// Gets or sets the Detail value.
		/// </summary>
		public string Detail {
			get { return detail; }
			set { detail = value; }
		}
		
		/// <summary>
		/// Gets or sets the ImageURL value.
		/// </summary>
		public string ImageURL {
			get { return imageURL; }
			set { imageURL = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityID value.
		/// </summary>
		public int CityID {
			get { return cityID; }
			set { cityID = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanguageID value.
		/// </summary>
		public int LanguageID {
			get { return languageID; }
			set { languageID = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_TravelTool table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_TravelToolInsert", tTID, tTName, description, detail, imageURL, cityID, languageID));
		}
		
		/// <summary>
		/// Updates a record in the TF_TravelTool table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_TravelToolUpdate", iD, tTID, tTName, description, detail, imageURL, cityID, languageID);
		}
		
		/// <summary>
		/// Deletes a record from the TF_TravelTool table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_TravelToolDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_TravelTool table.
		/// </summary>
		public static TF_TravelTool Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_TravelToolSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_TravelTool(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_TravelTool table.
		/// </summary>
		public static List<TF_TravelTool> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_TravelToolSelectAll")) {
				List<TF_TravelTool> tF_TravelToolList = new List<TF_TravelTool>();
				while (dataReader.Read()) {
					TF_TravelTool tF_TravelTool = MakeTF_TravelTool(dataReader);
					tF_TravelToolList.Add(tF_TravelTool);
				}
				return tF_TravelToolList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_TravelTool class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_TravelTool MakeTF_TravelTool(SqlDataReader dataReader) {
			TF_TravelTool tF_TravelTool = new TF_TravelTool();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_TravelTool.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_TravelTool.TTID = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_TravelTool.TTName = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_TravelTool.Description = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_TravelTool.Detail = dataReader.GetString(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_TravelTool.ImageURL = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_TravelTool.CityID = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_TravelTool.LanguageID = dataReader.GetInt32(7);
			}

			return tF_TravelTool;
		}
		#endregion
	}
}
